package com.example.ssm.controller;

import com.example.ssm.pojo.*;
import com.example.ssm.pojo.user.login.MessageModel_Login;
import com.example.ssm.pojo.user.login.RequestModel_Login;
import com.example.ssm.pojo.user.register.MessageModel_registered;
import com.example.ssm.pojo.user.register.RequestModel_registered;
import com.example.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Package: com.example.ssm.controller
 * @ClassName: UserControlller
 * @Author: 76470
 * @CreateTime: 2021/6/8 10:40
 * @Description:
 */
@CrossOrigin
@RestController
public class UserControlller {
	@Autowired
	private UserService userService;
	
	
	/*登录控制器*/
	@RequestMapping(value = "/user/login", method = {RequestMethod.POST,RequestMethod.GET})
	public MessageModel_Login UserLoginController ( @RequestBody(required = false) RequestModel_Login requestModel_login ){
		System.out.println ("当前进行服务为：登录（UserLogin）");
		System.out.println ("Controller接收到的userName：" + requestModel_login.getUserName () + "," + "接收到的passWord：" + requestModel_login.getPassWord ());//test
		return userService.UserLoginService (requestModel_login.getUserName (),requestModel_login.getPassWord ());
	}
//	public MessageModel_Login UserLoginController (String userName, String passWord ){
//		System.out.println ("Controller接收到的userName：" + userName + "," + "接收到的passWord：" + passWord);//test
//		return userService.UserLoginService (userName,passWord);
//	}
	
	/*获取用户信息控制器*/
	@GetMapping("/user/getinfo")
	public User UserGetInfoController(Integer token){
		System.out.println ("当前进行服务为：获取用户信息（UserGetInfo）");
		System.out.println ("Controller接收到的token:"+token);//test
		return userService.UserGetInfoService ( token );
	}
	
	/*注册控制器*/
	@RequestMapping(value = "/user/register", method = {RequestMethod.POST,RequestMethod.GET})
	public MessageModel_registered UserRegisteredController ( RequestModel_registered requestModel_registered ){
		System.out.println ("当前进行服务为：新用户注册（UserRegister）");//test
		System.out.println ("Controller接收到的userName:"+requestModel_registered.getUserName ()+", passWord:"+requestModel_registered.getPassWord ()+", introduction:"+requestModel_registered.getIntroduction ());//test
		return userService.UserRegisteredService ( requestModel_registered.getUserName (),
				requestModel_registered.getPassWord (), requestModel_registered.getIntroduction () );
	}
//	public MessageModel_registered UserRegisteredController( String userName, String passWord, String introduction ){
//		System.out.println ("当前进行服务为：新用户注册（UserRegister）");//test
//		System.out.println ("Controller接收到的userName:"+userName+", passWord:"+passWord+", introduction:"+introduction);//test
//		return userService.UserRegisteredService ( userName, passWord, introduction );
//	}


}
